#ifndef WIDGET_H
#define WIDGET_H

#include <QtGui/QWidget>
#include <QStyledItemDelegate>
#include <QPainter>

class MyDelegate : public QStyledItemDelegate {
public:
    MyDelegate(QObject *parent=0) : QStyledItemDelegate (parent){}

    void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const{
        if(option.state & QStyle::State_Selected){
            painter->fillRect(option.rect, option.palette.color(QPalette::Highlight));
        }

        QString title = index.data(Qt::DisplayRole).toString();
        QString description = index.data(Qt::UserRole + 1).toString();

        QRect r = option.rect.adjusted(50, 0, 0, -50);
        painter->drawText(r.left(), r.top(), r.width(), r.height(), Qt::AlignBottom|Qt::AlignLeft|Qt::TextWordWrap, title, &r);

        r = option.rect.adjusted(50, 50, 0, 0);
        painter->drawText(r.left(), r.top(), r.width(), r.height(), Qt::AlignLeft|Qt::TextWordWrap, description, &r);
    }

    QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const{
        return QSize(200, 100);
    }
};

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = 0);
    ~Widget();

private slots:
    void onbbb();
private:
    QWidget *w;
};

#endif // WIDGET_H
